﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Runtime.InteropServices;

namespace ConsoleApplication2
{
    class Program
    {
        delegate bool EnumWindowsCallBack(IntPtr hwnd, IntPtr param);

        [DllImport("user32.dll")]
        static extern int EnumWindows(EnumWindowsCallBack callback, IntPtr param);

        static bool PrintWindows(IntPtr hwnd, IntPtr param)
        {
            Console.WriteLine(hwnd.ToInt64());
            return true;
        }

        static void Main(string[] args)
        {
            EnumWindows(PrintWindows, IntPtr.Zero);
            Console.WriteLine("*************Press any key to exit**************");
            Console.ReadKey(true);
        }
    }
}
